package com.contextor.magiccards.model.battle;

import com.contextor.magiccards.model.BaseEntity;
import com.contextor.magiccards.model.character.Personage;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;

/**
 * User: sergey
 * Date: Apr 1, 2011 4:41:47 PM
 */
@Entity(name = "combat")
public class Combat extends BaseEntity {

/*
    @OneToMany(targetEntity = Personage.class, fetch = FetchType.LAZY, mappedBy = "")
    @Cascade(CascadeType.SAVE_UPDATE)
    @Fetch(FetchMode.JOIN)
*/
    private List<Personage> players = new ArrayList<Personage>(2);

    @Transient
    private int currentPlayer = 0;

    public List<Personage> getPlayers() {
        return players;
    }

    public void setPlayers(List<Personage> players) {
        this.players = players;
    }

    public int getCurrentPlayer() {
        return currentPlayer;
    }

    public void setCurrentPlayer(int currentPlayer) {
        this.currentPlayer = currentPlayer;
    }

    public boolean addCharacter(Personage personage) {
        return players.add(personage);
    }
}
